#include <fcntl.h> 
#include <stdio.h> 
#include <string.h> 
#include <sys/stat.h> 
#include <sys/types.h>
#include <unistd.h>

// http://www.techytalk.info/linux-system-programming-open-file-read-file-and-write-file/
#define BUF_SIZE 4096
int main(int argc, char* argv[]){
	if(argc < 2){
		printf("usage: ./a.out <fileName>\n");
		return 1;
	}

	char buf[BUF_SIZE];

	int fd = open(argv[1],O_RDWR);
	if(fd == -1){
		printf("open file fail%s\n", argv[1]);
		return 1;
	}

	while(read(fd, buf, BUF_SIZE) >0){
		// output
		printf("%s\n", buf);
		getchar();// wait
	}
	close(fd);
	
	return 0;
}